import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_learn_vi/src/bean/IntegralConfigEntity.dart';
import 'package:flutter_learn_vi/src/net/dio_utils.dart';
import 'package:flutter_learn_vi/src/page/common/common_loading_dialog.dart';

/// 创建人： Created by zhaolong
/// 创建时间：Created by  on 6/7/21.
///
/// 可关注公众号：我的大前端生涯   获取最新技术分享
/// 可关注网易云课堂：https://study.163.com/instructor/1021406098.htm
/// 可关注博客：https://blog.csdn.net/zl18603543572
///
/// 代码清单
///代码清单
class MineIntegralRoulesPage extends StatefulWidget {
  @override
  _MineIntegralRoulesPageState createState() => _MineIntegralRoulesPageState();
}

class _MineIntegralRoulesPageState extends State<MineIntegralRoulesPage> {
  IntegralConfigEntity _integralConfigEntity;
  bool _isLoading = true;

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    getConfigFunction();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text("积分规则"),
        ),
        backgroundColor: Colors.white,

        ///填充布局
        body: buildContext());
  }

  buildContext() {
    if (_isLoading) {
      return Center(
        child: LoadingWidget(),
      );
    }
    if (_integralConfigEntity == null) {
      return Center(
        child: Text("暂无详情"),
      );
    }

    return SingleChildScrollView(
      padding: EdgeInsets.zero,
      child: Container(
          padding: EdgeInsets.all(12),
          child: Text("${_integralConfigEntity.remark}")),
    );
  }

  void getConfigFunction() async {
    ResponseInfo appIntegralConfigRresponseInfo =
        await DioUtils.instance.getRequest(
      url: HttpHelper.integralConfigRouleUrl,
    );
    if (appIntegralConfigRresponseInfo.success) {
      _integralConfigEntity =
          IntegralConfigEntity.fromMap(appIntegralConfigRresponseInfo.data);
    }
    _isLoading = false;
    setState(() {});
  }
}
